<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Article_model extends DS_Model {

    protected $table = 'article'; 


	
	/**
	 * 审核数据
	 * @param  integer $audit 审核 0/1
	 * @param  array/integer  $ids   ID 标识
	 * @param  array/string   $where 条件
	 * @return int            影响数据行
	 */
	public function audit($audit=1,$ids,$where=FALSE,$table=FALSE)
	{	
		if (!$table) {
			$table = $this->table;
		}
		if (is_numeric($ids)) {
			$this->db->where(array('id'=>$ids));
		}

		if (is_array($ids)) {
			$this->db->where_in('id',$ids); 
		}

		if ($where) {
			$this->db->where($where); 
		}

		$data = array('audit'=>$audit,'status'=>$audit);
		$this->db->update($table,$data);
		return $this->db->affected_rows(); 
	}
	public function flag($flag=1,$ids,$where=FALSE,$table=FALSE)
	{
		if (!$table) {
			$table = $this->table;
		}
		if (is_numeric($ids)) {
			$this->db->where(array('id'=>$ids));
		}

		if (is_array($ids)) {
			$this->db->where_in('id',$ids);
		}

		if ($where) {
			$this->db->where($where);
		}

		$data = array('flag'=>$flag,'status'=>1);
		$this->db->update($table,$data);
		return $this->db->affected_rows();
	}
}